home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Tools / Preditor 2.0 / Preditor Folder / PCMD Source / MPW / Rotate13.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-02  |  887 b   |  42 lines  |  [TEXT/TCEd]

  1. /************************************************************
  2.  
  3.     Rotate13.c
  4.     Last Modified: Friday, May 31, 1991 at 9:46 PM
  5.     
  6.     Shift characters 13 positions
  7.  
  8.     © Copyright Evatac Software  1988-1990
  9.     All rights reserved
  10.  
  11. ************************************************************/
  12.  
  13. #include "PCMD.h"
  14.  
  15. main(
  16.     unsigned char        *sourceText,
  17.     long                sourceLength,
  18.     unsigned char        *destText,
  19.     long                *destSpace,
  20.     PCMDInfo            *info
  21.     )
  22. {
  23. #pragma unused(info)
  24.  
  25.     if (sourceLength > *destSpace)
  26.         return(kPCMDMoreSpace);
  27.         
  28.     *destSpace = sourceLength;
  29.     
  30.     while (sourceLength-- > 0) {
  31.         if (*sourceText >= 'A' && *sourceText <= 'Z')
  32.             *destText = ((*sourceText - 'A' + 13) % 26) + 'A';
  33.         else if (*sourceText >= 'a' && *sourceText <= 'z')
  34.             *destText = ((*sourceText - 'a' + 13) % 26) + 'a';
  35.         else
  36.             *destText = *sourceText;
  37.         sourceText++;
  38.         destText++;
  39.     }
  40.     return(kPCMDSuccess);
  41. }
  42.